<template>
  <div style="padding: 20px">
    <div id="splist" style=" border:solid 1px black;width: 800px;BACKGROUND-COLOR: rgba(248,248,248,1);
    padding: 20px;display: flex;flex-direction: column">
      <p style="text-align: center;line-height: 0px">盘点单</p>
      <div style="display: flex;justify-content: space-between">
        <div style="padding-left: 10px;box-sizing: border-box;">
          <p >盘点门店：{{sendForm.shopName}}</p>
          <p >盘点备注：{{sendForm.wxCheck.memo}}</p>
        </div>
        <div style="padding-left: 10px;box-sizing: border-box;">
          <p>盘点日期：{{sendForm.wxCheck.orderDate|dateFormatter}}</p>
          <p >盘点单号：{{sendForm.wxCheck.sn}}</p>
        </div>
      </div>
      <table border="1" cellspacing="0" width="770px">
        <tr>
          <td width="120px">商品条码</td>
          <td width="120px">商品名称</td>
          <td width="120px">规格</td>
          <td width="60px">单位</td>
          <td width="135px">账面库存</td>
          <td width="135px">实物库存</td>
          <td width="135px">损益数量</td>
          <td width="170px">备注</td>
        </tr>
        <tr v-for="item in sendForm.wxCheck.itemList">
          <td width="120px">{{item.sn}}</td>
          <td width="120px">{{item.name}}</td>
          <td width="120px">{{item.spec}}</td>
          <td width="50px">{{item.unit}}</td>
          <td width="120px"  align="center">{{item.bookQuantity}}</td>
          <td width="120px"  align="center">{{item.physicalQuantity}}</td>
          <td width="120px"  align="center">{{item.physicalQuantity-item.bookQuantity}}</td>
          <td></td>
        </tr>
        <tr>
          <td colspan="4">合计</td>
          <td  align="center">{{allQuantity}}</td>
          <td  align="center">{{allAmount}}</td>
          <td  align="center">{{allAmount-allQuantity}}</td>
          <td></td>
        </tr>
      </table>
      <div  style="display: flex;justify-content: space-between;padding-right: 100px;margin-top: 10px">
        <div>

          <p style="line-height: 0px">{{sysMchName}}</p>
        </div>
        <div>

          <p style="line-height: 0px">审核人签字：</p>
        </div>
      </div>
    </div>
  </div>
</template>

<script>
  import { getLodop,loadCLodop}  from '@/utils/lodop'
  import {find} from '@/api/order'
  import { getInfo } from '@/api/sysMch'

  export default {
    name: 'lodopOrder',
    data(){
      return{
        form:{},
        sysMchName:'',
        allQuantity:0,
        isShow:false,
        allDiscount:0,
        allAmount:0,
      }
    },
    props:['sendForm'],
    created() {

      loadCLodop()
      this.getMchName()
      this.sendForm.wxCheck.itemList.forEach(item=>{
        this.allQuantity+=item.bookQuantity
        this.allAmount+=item.physicalQuantity

      })
    },
    methods:{
      getMchName(){
        getInfo().then(res=>{
          this.sysMchName=res.data.name
        })
      },
      printPdf() {
        let LODOP = getLodop();
        if (LODOP == true || LODOP == 'undefined') {
          this.isShow = true
        }
        console.log(LODOP)
        this.$emit('isTeach', this.isShow)
        if (LODOP != true && LODOP != 'undefined') {
          // LODOP.PRINT_INIT("订货单");
          // LODOP.PRINT_DESIGN()
          LODOP.SET_PRINT_STYLE("FontSize", 1);
          // LODOP.SET_PRINT_STYLE("Bold", 1);
          // CreateOnePage()
          LODOP.SET_PRINT_MODE("PRINT_PAGE_PERCENT", "90%");
          // LODOP.SET_PRINT_PAGESIZE(1,57,0,'');
          LODOP.ADD_PRINT_HTM(88, 20, 400, 800, document.getElementById("splist").innerHTML);
          // LODOP.PRINT();
          LODOP.PREVIEW();

        }
      },
    }
  }
</script>

<style scoped>

</style>
